package com.gao.weblog.web.controller;

import com.gao.weblog.common.aspect.ApiOperationLog;
import com.gao.weblog.common.utils.PageResponse;
import com.gao.weblog.common.utils.Response;
import com.gao.weblog.web.module.vo.category.FindCategoryArticleListReqVO;
import com.gao.weblog.web.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.simpleframework.xml.core.Validate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/category")
@Api(tags = "分类")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @PostMapping("/list")
    @ApiOperation(value = "前台获取分类列表")
    @ApiOperationLog(description = "前台获取分类列表")
    public Response findCategoryList(){
        return categoryService.findCategoryList();
    }

    @PostMapping("/article/list")
    @ApiOperation(value = "获取分类列表下的文章数据")
    @ApiOperationLog(description = "获取分类列表下的文章数据")
    public PageResponse findCategoryArticleList(@RequestBody @Validate FindCategoryArticleListReqVO findCategoryArticleListReqVO){
        return categoryService.findCategoryArticleList(findCategoryArticleListReqVO);
    }


}
